Product comparison table build process
How to build a product comparison table
What you will build
One way to deliver a better customer experience and boost conversions is by adding a product comparison table in your discovery experiences. With Algolia Recommend you can let your users to compare similar products and help them find the right fit.
Usually found on a product description page, the product comparison table is a great user experience for specification-driven products, allowing your users to quickly and conveniently compare their selected product with popular related ones.
By creating a product comparison table that highlights the differences between similar products you can speed up the sales process and guide your users to make the right choice for them.
![]() | ![]() | ![]() | |
Title | JBL headset | Bose headset | SteelSeries headset |
Price | $180 | $350 | $200 |
Battery life | 30 hours | 40 hours | Doesn’t apply |
Charging time | 2 hours | 1 hour | Doesn’t apply |
Noise cancelling | |||
Wireless | |||
Fit | Over the ear | Over the ear | Over the ear |
Alternative items
This Recommend model helps you display a block of products that are related to the selected product. It looks at user interactions, such as clicks, to determine which products are similar to the selected ones.
How to add a product comparison table to your app
The building block for this custom layout is the useRelatedProducts()
Hook from the React InstantSearch library.
In a nutshell, you can quickly integrate a product comparison table in your product details page, by following a few steps.
It is easier to render the list of attributes and the retrieved recommendations by column. Keep in mind a few tips, like also sending the selected product to the custom widget and limiting the retrieved recommendations to 2 or 3, for comparison.
React InstantSearch
To shape the Related Products model in the product comparison table,
you will have to create a custom widget based on useRelatedProducts()
, and provide it with a custom item component in the itemComponent
prop.
You should also provide the currently selected product to the custom widget,
as well as limit the retrieved recommendation to two (or more, depending on your use case) by setting limit={2}
, as shown in the code example.
Create the custom widget
Retrieve the recommendations with useRelatedProducts()
,
then extract and format the attributes’ names that you will like to display in the table.
Ensure you exclude the image attribute.
In this example, most of the attributes have been exracted and each name capitalized.
Render the extracted attributes
Render these extracted and formatted attributes as a column.
Display each item by column
Display only the item attributes that are part of the comparison
Do this by rendering the custom itemComponent
prop for each item, as shown in the code below.
Create the custom item component
You will have to create the custom item component view. You will have to display each of the selected item attributes as a column, making sure that the column heights are the same as the ones from the attributes (left-most) column.
Customise how the item attributes should be displayed
In this example, a check or X icon is displayed for boolean attributes, but you can add more custom views, such as star rating for reviews.
Next steps
You’ve just built a product comparison table layout with Algolia Recommend.
Now you can start training your own Related Products model and build a product comparison table for your own app.
Further reading
- How to set up recommend
- Recommend overview: Algolia documentation |Algolia Academy